<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>分数线预测</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 600px;
            margin: auto;
            background: white;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h1 {
            color: #333;
        }
        label {
            margin-top: 10px;
        }
        select, button {
            margin-top: 5px;
            padding: 10px;
            width: 100%;
            box-sizing: border-box;
        }
        button {
            background-color: #007bff;
            color: white;
            border: none;
            cursor: pointer;
        }
        button:hover {
            opacity: 0.8;
        }
        p {
            margin-top: 20px;
        }
    </style>
    <script>
        async function predictScore() {
            const nationClass = document.getElementById('nationClass').value;
            const url = `http://localhost:8083/predict?nationClass=${encodeURIComponent(nationClass)}`;

            try {
                const response = await fetch(url, {
                    method: 'GET',
                    headers: {
                        'Content-Type': 'text/plain'
                    }
                });

                if (!response.ok) {
                    throw new Error(`HTTP error! status: ${response.status}`);
                }

                const score = await response.json();
                document.getElementById('result').textContent = `2025年的预测分数线是: ${Math.round(score)}`;
            } catch (error) {
                console.error('Error fetching data:', error);
                document.getElementById('result').textContent = `无法获取数据: ${error}`;
            }
        }
    </script>
</head>
<body>
<div class="container">
    <h1>分数线预测</h1>
    <label for="nationClass">选择专业:</label>
    <select id="nationClass">
        <option value="电子信息">电子信息</option>
        <option value="工学">工学</option>
        <!-- 根据实际情况添加更多专业选项 -->
    </select>
    <button onclick="predictScore()">预测分数线</button>
    <p id="result"></p>
</div>
</body>
</html>
